package com.kanshu.ksgb.fastread.doudou.module.book.adapter;

import android.content.Context;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.widget.TextView;

import com.kanshu.ksgb.fastread.doudou.R;
import com.kanshu.ksgb.fastread.doudou.base.baseadapter.abslistview.CommonAdapter;
import com.kanshu.ksgb.fastread.doudou.base.baseadapter.abslistview.ViewHolder;
import com.kanshu.ksgb.fastread.doudou.module.book.bean.BookMark;

import java.util.List;

/**
 * 阅读器书签适配器
 * Created by wcy on 2017\7\4 0004.
 */

public class BookmarkAdapter extends CommonAdapter<BookMark> {
    public BookmarkAdapter(Context context, int layoutId, List<BookMark> datas) {
        super(context, layoutId, datas);
    }
    @Override
    protected void convert(ViewHolder holder, BookMark item, int position) {
        TextView tv = holder.getView(R.id.tvMarkItem);

        SpannableString spanText = new SpannableString((position + 1) + ". " + item.title + ": ");
        spanText.setSpan(new ForegroundColorSpan(mContext.getResources().getColor(R.color.light_coffee)),
                0, spanText.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);

        tv.setText(spanText);

        if (item.desc != null) {
            tv.append(item.desc
                    .replaceAll("　", "")
                    .replaceAll(" ", "")
                    .replaceAll("\n", ""));
        }
    }
}
